package com.atmilan.quartz.model.entity.daigo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.fasterxml.jackson.annotation.JsonFormat;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 *
 * </p>
 *
 * @author hupeng
 * @since 2020-04-27
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class DaigoProductSku extends Model<DaigoProductSku> {

    private static final long serialVersionUID = 1L;

    /**
     * SKU ID
     */
    @TableId(value = "sku_id", type = IdType.INPUT)
    private String skuId;

    /**
     * 商品ID
     */
    private String goodsId;

    /**
     * 库存数量
     */
    private Integer stock;

    /**
     * 颜色
     */
    private String color;

    /**
     * 尺码
     */
    private String size;

    /**
     * 1是期货， 0是现货
     */
    private Integer qihuo;

    /**
     * 采集时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd  HH:mm:ss")
    private Date createTime;
    /**
     * 采集时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd  HH:mm:ss")
    private Date editTime;

    private Integer updateFlag;

    private String suk;

    @Override
    protected Serializable pkVal() {
        return this.skuId;
    }

    public String getAttrKey(){
        return this.goodsId+"-"+this.color+"-"+this.size;
    }

    public String getSuk(){
        if(StringUtils.isNotBlank(suk)){
            return suk;
        }
        List<String> sukList= new ArrayList<String>();
        if(StringUtils.isNotBlank(color)){
            sukList.add(color);
        }
        if(StringUtils.isNotBlank(size)){
            sukList.add(size);
        }
        return String.join(",",sukList);
    }
}
